package com.xiaoshuidi.cloud.module.rooms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xiaoshuidi.cloud.module.rooms.pojo.RoomDeviceStairPrice;
import com.xiaoshuidi.cloud.module.rooms.mapper.RoomDeviceStairPriceMapper;
import com.xiaoshuidi.cloud.module.rooms.pojo.RoomSdiotAssociation;
import com.xiaoshuidi.cloud.module.rooms.service.IRoomDeviceStairPriceService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 阶梯水电价格表 服务实现类
 * </p>
 *
 * @author James
 * @since 2023-06-07
 */
@Service
public class RoomDeviceStairPriceServiceImpl extends ServiceImpl<RoomDeviceStairPriceMapper, RoomDeviceStairPrice> implements IRoomDeviceStairPriceService {
    @Autowired
    RoomDeviceStairPriceMapper roomDeviceStairPriceMapper;
    @Override
    public List<RoomDeviceStairPrice> getRoomDeviceStairPriceList(Long devicePriceId) {
        QueryWrapper<RoomSdiotAssociation> wrapper = new QueryWrapper();
        wrapper.eq("room_device_id",devicePriceId);
        wrapper.eq("deleted","0");
        return roomDeviceStairPriceMapper.getRoomDeviceAssociationList(wrapper);
    }

    @Override
    public RoomDeviceStairPrice getRoomDeviceAssociationInfo(Long devicePriceId) {
        RoomDeviceStairPrice roomDeviceStairPrice=new RoomDeviceStairPrice();
        roomDeviceStairPrice.setPngPrice(roomDeviceStairPriceMapper.getRoomDeviceAssociationInfo("png_price","png_read",devicePriceId));
        roomDeviceStairPrice.setAmmterPrice(roomDeviceStairPriceMapper.getRoomDeviceAssociationInfo("ammter_price","ammter_read",devicePriceId));
        roomDeviceStairPrice.setColdWorterPrice(roomDeviceStairPriceMapper.getRoomDeviceAssociationInfo("cold_worter_price","cold_worter_read",devicePriceId));
        roomDeviceStairPrice.setHotWorterPrice(roomDeviceStairPriceMapper.getRoomDeviceAssociationInfo("hot_worter_price","hot_worter_read",devicePriceId));
        return roomDeviceStairPrice;
    }

    @Override
    public List<RoomDeviceStairPrice> getPrice(Long roomDeviceId) {
        return roomDeviceStairPriceMapper.getPrice(roomDeviceId);
    }
}
